#include <bits/stdc++.h>
using namespace std;
#define N 100
vector<int> count_num(N,0);
int tanxin(int money,int& n)
{

    vector<int> number_money(N,0);// {1,10,1}
    vector<int> single_money(N,0);//{10,20,50}

    for(int i=0;i<n;i++)
        cin>>single_money[i];

    for(int i=0;i<n;i++)
        cin>>number_money[i];

    if (money >= 0)
    {
        for (int i = n-1; i >= 0; i--)
        {
            int temp = single_money[i];
            count_num[i] = min(number_money[i],money/single_money[i]);
            money = money - count_num[i]*single_money[i];
        }
        return 0;
    }
    else
        return money;


}
int main()
{
    int n,m;
    cin>>n>>m;
    int sum_value = 0;
    if(! tanxin(m,n))
    {
        for(int i=0;i<n;i++)
            sum_value+=count_num[i];
    }
    cout<<sum_value;
    return 0;
}